<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name=viewport content="with=device-width,initial-scale=1.0">
<link href="../resource/bootstrap/css/bootstrap.min.css"
	rel="stylesheet">
<link href="../resource/css/basic.css" rel="stylesheet">
<script src="../resource/js/jquery.min.js"></script>
<script src="../resource/bootstrap/js/bootstrap.min.js"></script>
<script src="../resource/js/user.js"></script>
<script>
	$(function() {
		$('#loginout').click(logout);
		$('#userList button').click(updateUserRoles);
	});
</script>
<title>角色管理</title>
</head>
<body>
	<nav class="navbar navbar-primary navbar-fixed-top" role="invigation">
		<div class="navbar-header">
			<img class="img-responsive" src="../resource/image/header3.png" />
		</div>
		<ul class="user nav navbar-nav navbar-right">
			<li><a href="#">欢迎您，${admin.petName }</a></li>
			<li><a id="loginout" href="#" data-roles="admin"><i
					class="glyphicon glyphicon-off"></i> 退出登录 </a></li>
		</ul>
	</nav>
	<div>
		<nav class="col-md-2">
			<div class="row panel panel-default">
				<div class="panel-body">
					<div class="list-group">
						<a class="list-group-item" href="../admin">首页导航</a>
					</div>
					<div class="list-group">
						<a class="list-group-item" href="studentMajor">专业管理<span
							class="badge">2</span></a> <a class="list-group-item"
							href="publishDepartment">系别添加</a> <a class="list-group-item"
							href="publishMajor">专业添加</a>
					</div>
					<div class="list-group">
						<a class="list-group-item" href="lessonType">课程类别<span
							class="badge">2</span></a> <a class="list-group-item"
							href="publishOneType">课程一级类添加</a> <a class="list-group-item"
							href="publishTwoType">课程二级类添加</a>
					</div>
					<div class="list-group">
						<a class="list-group-item active" href="userRoles">角色权限管理</a>
					</div>
					<div class="list-group">
						<a class="list-group-item" href="#">公告发布</a>
					</div>
					<div class="list-group">
						<a class="list-group-item" href="#">系统信息<span class="badge">1</span></a>
						<a class="list-group-item" href="#">异常信息</a>
					</div>
					<div class="list-group">
						<a class="list-group-item" href="systemInfo">性能监测</a>
					</div>
				</div>
			</div>
		</nav>
		<div class="col-md-10">
			<div class="row panel panel-default">
				<div class="panel-heading">
					<ol class="breadcrumb">
						<li><a href="../admin"><i
								class="glyphicon glyphicon-home"></i> 首页</a></li>
						<li class="active">角色管理</li>
					</ol>
				</div>
				<div class="panel-body">
					<div class="panel panel-default">
						<table id="userList"
							class="table table-striped table-bordered table-hover table-condensed">
							<tr>
								<th>Id</th>
								<th>头像</th>
								<th>账户</th>
								<th>用户名</th>
								<th>创建时间</th>
								<th>最后登录</th>
								<th>登录次数</th>
								<th>角色</th>
								<th>操作</th>
							</tr>
							<c:forEach items="${userList }" var="user">
								<tr>
									<td>${user.id }</td>
									<td class="col-sm-1"><span
										class="col-sm-10 col-sm-offset-1"><img
											class="img-responsive" src="${user.logo }" /></span></td>
									<td>${user.userNum }</td>
									<td>${user.petName }</td>
									<td>${fn:substring(user.createDate,0,19)}</td>
									<td>${fn:substring(user.lastLoginDate,0,19)}</td>
									<td>${user.loginNum }</td>
									<td><select class="form-control">
											<c:forEach items="${userRolesList }" var="url">
												<c:choose>
													<c:when test="${url.id == user.userRoles.id }">
														<option selected="selected" value="${url.id }">${url.rolesName }</option>
													</c:when>
													<c:otherwise>
														<option value="${url.id }">${url.rolesName }</option>
													</c:otherwise>
												</c:choose>
											</c:forEach>
									</select></td>
									<td>
										<button class="btn btn-success" data-id="${user.id }"
											type="button">提交更改</button>
									</td>
								</tr>
							</c:forEach>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>